
// key recogniser function is used to verify the key sent form the client.

key_recogniser = function(p_client){
	
	m_z = 36969 * (m_z & 65535) + (m_z >> 16);
	m_w = 18000 * (m_w & 65535) + (m_w >> 16);
	
	keyServer = (m_z << 16) + m_w; 
	
	trace("---key is---", keyServer);
	
	p_client.call("send_key", new keyHandler());  //call client function to request unique keys 
												  //to be verified to continue streaming
	keyClient = keyServer;								  
	if(keyClient == keyServer)
	{	
		trace("---key verified is---",keyClient);
		return;
	}
	else
	{   
		application.rejectConnection(p_client);
		return;
	}
	
}

keyHandler = function(){
		this.onResult = function(res){
			trace("Key received: " + res);
			keyClient = res;
		}
		this.onStatus = function(info){
			trace("Failed with code:" + info.code);
		}
};

